-- deathmsg
-- jadedctrl; GPLv3+

minetest.register_on_dieplayer(function(player)
	messagesA = { "~ has had life torn violently from their grasp.",
		"~ swore on their life... too bad it was a bluff.",
		"~ was murdered by the invisible hand.",
		"~ wasn't worthy anyway.",
		"Fortunately for ~, if you die in Minetest you do not die in real life.",
		"~ has been slain.",
		"~ rolled poorly.",
		"Reflect on your choices, ~.",
		"~, did your life flash before your eyes?",
		"~, what is it you cling to?",
		"~'s ghost would like to have a word with you.",
		"You musn't dwell, ~.",
		 "Don't be upset, but ~'s malfunctioned.",
		 "~ is broken, but lifetime warranty doesn't cover death." }

	messagesB = { "Let us go out this evening for pleasure, ~. The night is still young...",
		"Don't have negative thoughts. ~, remember your mantra." }

	messageList = math.random(1, 6)

	if ( 1 <= messageList and messageList <= 4 )
	then
		messageNo = math.random(1, table.getn(messagesA))
		message = messagesA[messageNo]
	else
		messageNo = math.random(1, table.getn(messagesB))
		message = messagesB[messageNo]
	end

	message = message:gsub("~", player:get_player_name())

	minetest.chat_send_all(message)
end)
